<%--
  Created by IntelliJ IDEA.
  User: bchen
  Date: 2014/8/27
  Time: 21:06
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>--%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="session"/>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>忘记密码</title>
    <link rel="stylesheet" media="screen" href="${path}/plugins/validate/validate.css">
    <link href="${path}/style/acg/css/style.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .code
        {

            font-family:Arial;
            font-style:italic;
            color:Red;
            letter-spacing:3px;
            font-weight:bolder;
            float:left; width:108px; height:38px;border: 1px solid #DDDDDD;
            text-align: center;
            background-color: whitesmoke;
        }

    </style>
    <script src="${path}/js/jquery.min.js" type="text/javascript"></script>
    <script>

        (function($){
            $.fn.serializeJson=function(){
                var serializeObj={};
                $(this.serializeArray()).each(function(){
                    serializeObj[this.name]=this.value;
                });
                return serializeObj;
            };
            $.errorHanld=function(msg){
                $("."+msg).fadeIn(1000).fadeOut(5000);
                //$("#jcimg").trigger("click");
                createCode();//刷新验证码
            };
        })(jQuery);

        $(function(){

            $("#errorMsg").hide();
            $("#okMsg").hide();

            createCode();//刷新验证码

            $("#loginsubmit").click(function(){

                if(!validateCode()){
                    return false;
                }

                var data = JSON.stringify($("#loginfrom").serializeJson());

                jQuery.ajax( {
                    type : 'POST',
                    contentType : 'application/json',
                    url : '${path}/forgetPassWord/resettingPwd.html',
                    data : data,
                    dataType : 'json',
                    success : function(data) {
                        <%--if(data.result){--%>
                            <%--window.location.href = '${path}/home/index.html';--%>
                        <%--}else{--%>
                            <%--$.errorHanld(data.msg);--%>
                        <%--}--%>
                        console.log(data);

                        if(data.status == "true"){

                            $("#okMsg").html(data.msg);

                            $("#errorMsg").hide();
                            $("#okMsg").show();
                        }else{

                            $.errorHanld(data.errorLabel);
                            $("#errorMsg").html(data.msg);
                            $("#errorMsg").show();
                            $("#okMsg").hide();
                        }
                    },
                    error : function(data) {
                        $.errorHanld(data.msg);
                    }
                });
            });
            document.onkeydown = function(e){
                    var ev = document.all ? window.event : e;
                    if(ev.keyCode==13) {
                        $("#loginsubmit").trigger("click");
                    }
                }
        });

        //-----------------
        var code ; //在全局 定义验证码
        function createCode()
        {
            code = "";
            var codeLength = 5;//验证码的长度
            var checkCode = document.getElementById("checkCode");
            var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');//所有候选组成验证码的字符，当然也可以用中文的

            for(var i=0;i<codeLength;i++)
            {


                var charIndex = Math.floor(Math.random()*36);
                code +=selectChar[charIndex];


            }
//       alert(code);
            if(checkCode)
            {
                checkCode.className="code";
                checkCode.value = code;
            }

        }

        function validateCode ()
        {
            var inputCode = document.getElementById("verifcode").value;

            if(inputCode.toUpperCase() != code )
            {
                $.errorHanld("vercImg");
                return false;
            }
            else
            {
               return true;
            }

        }

    </script>
<body>
<jsp:include page="../public/header.jsp"></jsp:include>
<form id="loginfrom">
<div id="container">
    <div class="wrapper">
        <div class="border">
            <div class="modetitle">
                忘记密码
            </div>
            <div class="regloginbox">
                <div class="formbox">
                    <ul>
                        <li class="clearfix">
                            <dl>
                                <dt><spring:message code='login.message.msg2' /></dt>
                                <dd>
                                    <input type="text" id="name" name="name" class="txt328" value="" />
                                    <img class="userImg" src="${path}/style/common/images/erase.png" style="display: none"   border="0">
                                </dd>
                            </dl>
                        </li>
                        <li class="clearfix">
                            <dl>
                                <dt>认证邮箱：</dt>
                                <dd>
                                    <input type="text" id="email" name="email" class="txt328" value="" />
                                    <img class="emailImg" src="${path}/style/common/images/erase.png" style="display: none"   border="0">
                                </dd>
                            </dl>
                        </li>
                        <li class="clearfix">
                            <dl>
                                <dt>注册手机：</dt>
                                <dd>
                                    <input type="text" id="phone" name="phone" class="txt328" value="" />
                                    <img class="phoneImg" src="${path}/style/common/images/erase.png" style="display: none"   border="0">
                                </dd>
                            </dl>
                        </li>
                        <li class="clearfix">
                            <dl>
                                <dt><spring:message code='login.message.msg4' /></dt>
                                <dd>
                                    <input type="text" id="verifcode" name="verifcode" class="txtcode" value="" />
                                    <%--<img id="jcimg" src="${path}/jcaptcha"  class="imgcode"  onclick="javascript:this.src='${path}/jcaptcha?'+Math.random();">--%>
                                    <input type="text" onclick="createCode()" readonly="readonly" id="checkCode" class="imgcode"  />
                                    <img class="vercImg" src="${path}/style/common/images/erase.png" style="display: none"  border="0">
                                </dd>
                            </dl>
                        </li>
                        <li class="clearfix">
                            <dl>
                                <dt>&nbsp;</dt>
                                <dd>
                                   <label id="errorMsg" class="error"></label>
                                   <label id="okMsg" style="font-weight: bold;color: #EA5200;"></label>
                                </dd>
                            </dl>
                        </li>

                        <li class="clearfix">
                            <dl>
                                <dt>&nbsp;</dt>
                                <dd><input type="button" id="loginsubmit" name="" value="重置密码" class="btn_org" /><label>

                                </label></dd>
                            </dl>
                        </li>

                    </ul>
                </div>
                <div class="formright">

                    <a href="${path}/login/index.html" class="btn_grey"><spring:message code="login.login" /></a>
                </div>
                <div class="clr"></div>
            </div>
        </div>
    </div>
</div>
</form>
<jsp:include page="../public/footer.jsp"></jsp:include>
</body>
</html>

